home *** CD-ROM | disk | FTP | other *** search
- Path: ns.cs.hku.hk!sdlee
- From: sdlee@cs.hku.hk (Lee Sau Dan ~{@nJX6X~})
- Newsgroups: hku.open-forum,hk.comp.pc,comp.lang.c++,comp.lang.pascal.misc
- Subject: Re: Is Pascal worth to learn? Can it help me to get a job?
- Date: 16 Jan 1996 02:50:19 GMT
- Organization: Computer Science Dept, University of Hong Kong
- Message-ID: <SDLEE.96Jan16105019@champion.cs.hku.hk>
- References: <30f2adf8.7810115@news.hku.hk> <DL2tFM.7DJ@hkuxb.hku.hk>
- <4dcrl0$7mo_001@news.hku.hk> <SDLEE.96Jan15161338@champion.cs.hku.hk>
- <4devt9$844_001@news.hku.hk>
- NNTP-Posting-Host: champion.cs.hku.hk
- In-reply-to: kong@hkusua.hku.hk's message of Tue, 16 Jan 1996 01:44:09 GMT
-
- In article <4devt9$844_001@news.hku.hk> kong@hkusua.hku.hk (someone) writes:
-
- >> I do agree using the swapping method I mentioned is not a
- >> common practice (and I myself never have to do it). But it does
- >> demonstrate the power of a language.
-
- Is that really the power of a computer language, or just the power of
- some mathematical tricks? How much is it faster? Mind you that
- optimizing compilers are able to allocate a temp. variable in a
- register for this swapping purpose. If it just makes the code
- more difficult to understand, then think twice before you write it.
-
-
- >> Bit-vectors ARE required in many cases, and I strongly
- >> disagree that they are difficult to debug or maintain. There
- >> are cases when there will be matrixes with hundreds or at times
- >> millions of elements, each containing just a few boolean
- >> values. It will be much easier to debug and maintain the code
- >> by using bit-vectors and use masks defined as constants to set
- >> or get the required bits. Not to mention the memories saved
- >> compared to using arrays of booleans.
-
- Well... Bit-vectors are good only if the word length is always the
- same on all machines. The size of an 'int' can be different on
- different platforms and compilers. For example, the 'int' in
- Borland C is 16-bit long, while that in GCC is 32-bit long.
- Writing portable programs using bit-vectors is a headache. It is
- not just a simple task of applying masks.
-
- Yes, I agree that memory can be saved by using bit vectors. However,
- manipulations on bit vectors are usually not as fast as manipulations
- on integer. This is because intergers are more native to many processors
- than single bits. That's why many people (even assembler programmers
- and compilers) simply use an 'int' for a boolean variable. They are
- faster and memory is "cheap". Unless you intend to do operations
- on several bits at a time, using bit vectors won't save you much time.
-
- Of course, if your boolean array is long, you may want to optimize
- the memory usage by using bit vectors. However, there is also
- something know as "packed array" in Pascal!
-
-
- >> Er.. right. While I said that in my post I was responding to
- >> the original poster's claim that Pascal can do everything other
- >> language can do.
-
- That's true. Pascal can do everything other languages can do. I'm
- not talking about machine specific operations (e.g. controlling DMA
- and IRQ), of course. In the most extreme case, you can write a C
- interpreter in Pascal. Then, for any C program you write, the
- interpreter (a Pascal program) can do exactly the same things as your
- C program.
-
-
- >> The ability to cast a pointer to something else is a two side
- >> sword. A good programmer can make use of it wisely. Lousy
- >> programmers make pointer errors out of it.
-
- That's a reason why Pascal is easier for beginners than C. Do you
- remember the nightmares with C strings when you were learning C?
- Pointers in C is flexible. It is a powerful tool if you can manage to
- use it properly. For beginners, it is often the killer of their
- programs! An an analog, a knife is a useful tool. You can use it to
- cut food. However, if kids use it improperly, it hurts them.
-
-
- >> Out-of-bound array references can happen in Pascal, if you
- >> turn-off your run-time array bound checking.
-
- Do all Pascal compilers offer this option? Even if a compiler supports
- such an option, it should be disabled by default.
-
-
- >> Again, pointers arithmetic in C is a two side sword.
-
- Agree! Whenever something is powerful enough to be useful, it is also
- powerful enough to be harmful. Pencils are not sharpened at both ends.
-
-
-
- --
- Lee Sau Dan
-
- -------------------------------------------------------------------------------
- URL: http://www.cs.hku.hk/~sdlee
- e-mail: sdlee@cs.hku.hk
-